module AliasingColumns 
	

	@adapter = Rails::Configuration.new.database_configuration[RAILS_ENV]["adapter"]

	def self.add_aliases allcolumns
	allcolumns.each do |arg|
		if(arg.name.to_s!="PASSWORD" && arg.name.to_s!="password")
			#from mixedCase to current name in db
	    	 method_name = translate_name(arg.name.to_s)   
	      	 send :define_method, method_name do
	       	 	self[arg.name.to_s]
	      	 end
	      	 
	      	 method_name = (translate_name(arg.name.to_s))<<"="   
	      	 send :define_method, method_name do |new_value| 
	       	 	self.write_attribute(arg.name.to_s,new_value)
	      	 end
	      	 	#from current name in uppercase to current name
=begin 
	      	 method_name = arg.name.to_s.upcase   #(arg.name.to_s.downcase).to_sym
	      	 send :define_method, method_name do
	       	 	self[arg.name.to_s]
	      	 end
	      	 method_name = (arg.name.to_s.upcase)<<"="   #(arg.name.to_s.downcase).to_sym
	      	 send :define_method, method_name do |new_value| 
	       	 	self.write_attribute(arg.name.to_s,new_value)
	      	 end
=end
			      	 
	    	end
		
		end

		
	end
	# translate_name (arg.name.to_s)   #(
	
	def self.translate_name input
		result=input.downcase
		result=result.gsub("id","ID")
		result=result.gsub(/_\w/){
		  |v|
		  v.replace(v[1..1].upcase)
		}
		return result
	end

	def self.get_adapter_name
		@adapter
	end
		
end


